﻿@using Lavka.Core
@model IEnumerable<Lavka.Models.Products>
           
@foreach (var item in Model) 
{
    <tr>
        @if (Request.IsAuthenticated)
        {
            <td>
                @Html.ActionLink("Редактировать", "Edit", "Products", new { id = item.ProductId }, null) |
                @Html.ActionLink("Удалить", "Delete", "Products", new { id = item.ProductId }, null)
            </td>
        }            
        <td style="border-right: solid 1px #e3e1e1;">
            @if (!string.IsNullOrEmpty(item.Photo))
            {
                <a href="@Url.Content(item.Photo)" title="@item.Name" class="thickbox"><img src="@Url.Content(item.Photo)" alt="@item.Name" class="small-image" /></a>
            }
        </td>
        <td style="border-right: solid 1px #e3e1e1;">
            @if (!string.IsNullOrEmpty(item.Name))
            {
                @Html.ActionLink(item.Name, "Details","Products", new {id = item.ProductId}, null)
            }
        </td>
        <td style="border-right: solid 1px #e3e1e1;">
			@item.Reference
        </td>
        <td style="border-right: solid 1px #e3e1e1;">
			@item.Brands.Name
        </td>
        <td style="border-right: solid 1px #e3e1e1;">
			@item.Caterories.Name
        </td>
        <td style="border-right: solid 1px #e3e1e1;">
            <span class="tablePrice">@String.Format("{0:0.00}", item.Price) грн.</span>
        </td>
        <td style="border-right: solid 1px #e3e1e1;">
            @if (!CartHelper.IsProductInCart(item))
            {
                     <div>
                        <a href="@Url.Content("~/Products/AddToCart/"+ item.ProductId)">
                            <img src="@Url.Content("~/Content/images/cart-green.png")" alt="@item.Name"/>
                        </a>
                     </div>
            }
            else
            {
                <div>Добавлен</div>
            } 
        </td>
    </tr>
}
<script type="text/javascript">
    $(document).ready(initPopupImage());
</script>